<?php

namespace Modules\Admin\Http\Controllers\Configurations;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Configurations;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Retrieve
{

    /**
     * @Route(path=/api/admin/configuration)
     */
    public function retrieve()
    {
        $query = Configurations::with(['adminUser']);
        //名称
        if (request('name')) {
            $query->where('name', 'like', '%' . request('name') . '%');
        }

        //分类状态
        if (request('is_enabled')) {
            $query->where('is_enabled', '=', request('is_enabled'));
        }
        $query->orderByRaw('id desc , updated_at desc');
        $sidDefault = auth('api')->user()->sid;
        $eidDefault = auth('api')->user()->eid; 
        $data = $query->where('sid',$sidDefault)->where('eid',$eidDefault)->paginate(request('per_page', 15));

        return Api::success($data);
    }

}